package com.study.hospital_3.controller;

import com.study.hospital_3.pojo.Medicalfree;
import com.study.hospital_3.service.impl.MedicalfreeServiceImpl;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * 病人看病费用表(Medicalfree)表控制层
 *
 * @author makejava
 * @since 2025-01-20 17:03:47
 */
@RestController
@RequestMapping("medicalfree")
@Api(value = "病人看病费用表(Medicalfree)",tags = "病人看病费用表(Medicalfree)接口API")
public class MedicalfreeController {
    /**
     * 服务对象
     */
    @Resource
    private MedicalfreeServiceImpl medicalfreeServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
    @GetMapping("/selectAll")
    public Map<String, Object> selectAll(Medicalfree medicalfree) {
        return medicalfreeServiceImpl.selectAll(medicalfree);
    }

    /**
     * 分页查询
     *
     * @param medicalfree 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("/selectByLimit")
    public Map<String, Object> selectByLimit(Medicalfree medicalfree, @RequestParam int page, @RequestParam int limit) {
        return medicalfreeServiceImpl.selectByLimit(medicalfree, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return medicalfreeServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param medicalfree 实体
     * @return 新增结果
     */
    @PostMapping("/insert")
    public Map<String, Object> insert(@RequestBody Medicalfree medicalfree) {
        return medicalfreeServiceImpl.insert(medicalfree);
    }

    /**
     * 编辑数据
     *
     * @param medicalfree 实体
     * @return 编辑结果
     */
    @PostMapping("/updateById")
    public Map<String, Object> updateById(@RequestBody Medicalfree medicalfree) {
        return medicalfreeServiceImpl.updateById(medicalfree);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @PostMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return medicalfreeServiceImpl.deleteById(id);
    }

}

